package com.yy.micro.magic.data.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.yy.micro.magic.data.entity.CodeMapItemEntity;
import com.yy.micro.magic.data.model.vo.JpaObjectWithDynamicFieldsVo;
import com.yy.micro.magic.ext.domain.code.CodeMapItem;

public class CodeItemVo extends JpaObjectWithDynamicFieldsVo {
    private Long itemId;
    private Long codeId;
    private String codeName;
    private String srcItemName;
    private String srcValue;
    private String targetItemName;
    private String targetValue;
    private String description;
    private boolean disable;

    public Long getItemId() {
        return itemId;
    }

    public void setItemId(final Long itemId) {
        this.itemId = itemId;
    }

    public Long getCodeId() {
        return codeId;
    }

    public void setCodeId(final Long codeId) {
        this.codeId = codeId;
    }

    public String getCodeName() {
        return codeName;
    }

    public void setCodeName(final String codeName) {
        this.codeName = codeName;
    }

    public String getSrcItemName() {
        return srcItemName;
    }

    public void setSrcItemName(final String srcItemName) {
        this.srcItemName = srcItemName;
    }

    public String getSrcValue() {
        return srcValue;
    }

    public void setSrcValue(final String srcValue) {
        this.srcValue = srcValue;
    }

    public String getTargetItemName() {
        return targetItemName;
    }

    public void setTargetItemName(final String targetItemName) {
        this.targetItemName = targetItemName;
    }

    public String getTargetValue() {
        return targetValue;
    }

    public void setTargetValue(final String targetValue) {
        this.targetValue = targetValue;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(final String description) {
        this.description = description;
    }

    public boolean isDisable() {
        return disable;
    }

    public void setDisable(final boolean disable) {
        this.disable = disable;
    }

    @JsonIgnore
    public static CodeItemVo create(){
        return new CodeItemVo();
    }

    @JsonIgnore
    public CodeItemVo from(CodeMapItemEntity entity){
        super.from(entity);
        setCodeId(entity.getCodeId());
        setDescription(entity.getDescription());
        setDisable(entity.isDisable());
        setItemId(entity.getItemId());
        setCodeName(entity.getCodeName());
        setSrcItemName(entity.getSrcItemName());
        setSrcValue(entity.getSrcValue());
        setTargetItemName(entity.getTargetItemName());
        setTargetValue(entity.getTargetValue());
        return this;
    }

    @JsonIgnore
    public CodeMapItemEntity to(){
        CodeMapItemEntity entity = new CodeMapItemEntity();
        super.to(entity);
        entity.setCodeId(getCodeId());
        entity.setDescription(getDescription());
        entity.setCodeId(getCodeId());
        entity.setCodeName(getCodeName());
        entity.setDisable(isDisable());
        entity.setItemId(getItemId());
        entity.setSrcItemName(getSrcItemName());
        entity.setSrcValue(getSrcValue());
        entity.setTargetItemName(getTargetItemName());
        entity.setTargetValue(getTargetValue());
        return entity;
    }
    @JsonIgnore
    public CodeMapItem toDomain(){
        CodeMapItem item = new CodeMapItem();
        item.setCodeName(getCodeName());
        item.setSrcItemName(getSrcItemName());
        item.setDescription(getDescription());
        item.setTargetItemName(getTargetItemName());
        item.setTargetValue(getTargetValue());
        item.setSrcValue(getSrcValue());
        return item;

    }
}
